package bstsetcode.stanforduniversity18;

/**
 * @author noob
 * @version 1.0
 * @date 2021/3/15 21:27
 * 给定一个有序链表， 中含有复节点，删除链表中的重复节点，使得每个不同值的节点只有一个
 */
public  class _10_RemoveDup {

    public static ListNode removeDup(ListNode head){

        ListNode cur = head;
        while (cur !=null){
            if(cur.val == cur.next.val){
                cur.next = cur.next.next;
                cur=cur.next;
            }else{
                cur=cur.next;
            }
        }
        return head;
    }


    public static void main(String[] args) {
        int[] nums3 = {5,6,6,7,8,9,9};
        ListNode headB = new ListNode(nums3);
        ListNode res = _10_RemoveDup.removeDup(headB);
        System.out.println(res);
    }



}
